import urllib
import urllib.request
import urllib.parse
from urllib.error import URLError, HTTPError
import http.client

#params = urllib.parse.urlencode({'page': '1'})
params = r'UserLogin%5Btype%5D=0&UserLogin%5Busername%5D=123131312312313&UserLogin%5Bpassword%5D=1231312&UserLogin%5BverifyCode%5D=hubl&ajax=user-login-form'
headers = {"Content-type": "application/x-www-form-urlencoded",\
           "Accept": "application/json, text/javascript, */*; q=0.01",\
           "X-Requested-With":"XMLHttpRequest"}
conn = http.client.HTTPConnection('dingxifund.com')
conn.request("POST", "/user/login",params,headers)
r1 = conn.getresponse()
print(r1.status, r1.reason)
print(r1.read().decode('utf-8'))
##print(r1.read().decode('GB2312'))
#url="http://www.cnbeta.com/newread.php"  
  
##values={"page":"1"}  
##data=urllib.parse.urlencode(values)  
##  
##theurl=url+"?"+data
##print(theurl)
###创建请求对象  
##req=urllib.request.Request(theurl)
##req.add_header("Content-Type","text/html;charset=GB2312")  
###获得服务器返回的数据
##response=urllib.request.urlopen(req)
###处理数据  
##page=response.read()
##print(page)
